/*    */ package com.zimbra.cs.service.admin;
/*    */ 
/*    */ import com.zimbra.common.account.Key.AccountBy;
/*    */ import com.zimbra.common.service.ServiceException;
/*    */ import com.zimbra.common.soap.AdminConstants;
/*    */ import com.zimbra.common.soap.Element;
/*    */ import com.zimbra.common.soap.SoapFaultException;
/*    */ import com.zimbra.cs.account.Account;
/*    */ import com.zimbra.cs.account.AccountServiceException;
/*    */ import com.zimbra.cs.account.Provisioning;
/*    */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*    */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*    */ import com.zimbra.cs.datasource.DataSourceManager;
/*    */ import com.zimbra.soap.ZimbraSoapContext;
/*    */ import java.util.List;
/*    */ import java.util.Map;
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ 
/*    */ public class DeleteDataSource
/*    */   extends AdminDocumentHandler
/*    */ {
/* 38 */   private static final String[] TARGET_ACCOUNT_PATH = { "id" };
/* 39 */   protected String[] getProxiedAccountPath() { return TARGET_ACCOUNT_PATH; }
/*    */   
/*    */ 
/*    */ 
/*    */   public boolean domainAuthSufficient(Map context)
/*    */   {
/* 45 */     return true;
/*    */   }
/*    */   
/*    */   public Element handle(Element request, Map<String, Object> context) throws ServiceException, SoapFaultException {
/* 49 */     ZimbraSoapContext zsc = getZimbraSoapContext(context);
/* 50 */     Provisioning prov = Provisioning.getInstance();
/*    */     
/* 52 */     String id = request.getAttribute("id");
/* 53 */     Map<String, Object> attrs = AdminService.getAttrs(request);
/*    */     
/* 55 */     Account account = prov.get(Key.AccountBy.id, id, zsc.getAuthToken());
/* 56 */     if (account == null) {
/* 57 */       throw AccountServiceException.NO_SUCH_ACCOUNT(id);
/*    */     }
/* 59 */     checkAdminLoginAsRight(zsc, prov, account);
/*    */     
/* 61 */     Element dsEl = request.getElement("dataSource");
/* 62 */     String dsId = dsEl.getAttribute("id");
/* 63 */     Provisioning.getInstance().deleteDataSource(account, dsId);
/*    */     
/* 65 */     DataSourceManager.cancelSchedule(account, dsId);
/*    */     
/* 67 */     Element response = zsc.createElement(AdminConstants.DELETE_DATA_SOURCE_RESPONSE);
/* 68 */     return response;
/*    */   }
/*    */   
/*    */   public void docRights(List<AdminRight> relatedRights, List<String> notes)
/*    */   {
/* 73 */     relatedRights.add(Rights.Admin.R_adminLoginAs);
/* 74 */     relatedRights.add(Rights.Admin.R_adminLoginCalendarResourceAs);
/* 75 */     notes.add("If the target is an account, need the adminLoginAs right; If the target is a calendar resource, need the R_adminLoginCalendarResourceAs right.");
/*    */   }
/*    */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/cs/service/admin/DeleteDataSource.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */